package com.dongfanggroup.report.service.impl;

import com.dongfanggroup.report.domain.ReportType;
import com.dongfanggroup.report.mapper.ReportTypeMapper;
import com.dongfanggroup.report.service.IReportTypeService;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 故障类型Service业务层处理
 *
 * @author wangsr
 * @date 2021-12-16
 */
@Service
public class ReportTypeServiceImpl implements IReportTypeService {
    @Autowired
    private ReportTypeMapper reportTypeMapper;

    /**
     * 查询故障类型
     *
     * @param id 故障类型主键
     * @return 故障类型
     */
    @Override
    public ReportType selectReportTypeById(Long id) {
        return reportTypeMapper.selectReportTypeById(id);
    }

    /**
     * 查询故障类型列表
     *
     * @param reportType 故障类型
     * @return 故障类型
     */
    @Override
    public List<ReportType> selectReportTypeList(ReportType reportType) {
        return reportTypeMapper.selectReportTypeList(reportType);
    }

    /**
     * 新增故障类型
     *
     * @param reportType 故障类型
     * @return 结果
     */
    @Override
    public int insertReportType(ReportType reportType) {
        reportType.setCreateTime(DateUtils.getNowDate());
        reportType.setCreateBy(SecurityUtils.getUserId().toString());
        return reportTypeMapper.insertReportType(reportType);
    }

    /**
     * 修改故障类型
     *
     * @param reportType 故障类型
     * @return 结果
     */
    @Override
    public int updateReportType(ReportType reportType) {
        return reportTypeMapper.updateReportType(reportType);
    }

    /**
     * 批量删除故障类型
     *
     * @param ids 需要删除的故障类型主键
     * @return 结果
     */
    @Override
    public int deleteReportTypeByIds(Long[] ids) {
        return reportTypeMapper.deleteReportTypeByIds(ids);
    }

    /**
     * 删除故障类型信息
     *
     * @param id 故障类型主键
     * @return 结果
     */
    @Override
    public int deleteReportTypeById(Long id) {
        return reportTypeMapper.deleteReportTypeById(id);
    }

    @Override
    public List<ReportType> selectReportTypeByPid(Integer pid) {
        return reportTypeMapper.selectReportTypeByPid(pid);
    }
}
